﻿using System;

namespace BSDS.Commands.Commands
{
    public class CommandResult
    {
        public CommandExitStatus ExitStatus { get; private set; }
        public string ShortMessage { get; private set; }
        public string DetailedMessage { get; private set; }

        private CommandResult(CommandExitStatus exitStatus, string shortMessage, string detailedMessage)
        {
            ExitStatus = exitStatus;
            ShortMessage = shortMessage;
            DetailedMessage = detailedMessage;
        }

        public static CommandResult Success()
        {
            return new CommandResult(CommandExitStatus.Success, string.Empty, string.Empty);
        }

        public static CommandResult Error(Exception exception)
        {
            return new CommandResult(CommandExitStatus.Error, exception.Message, exception.ToString());
        }

        public static CommandResult Error(string shortMessage, string detailedMessage)
        {
            return new CommandResult(CommandExitStatus.Error, shortMessage, detailedMessage);
        }

        public static CommandResult Warning(string warningMessage)
        {
            return new CommandResult(CommandExitStatus.Warning, warningMessage, string.Empty);
        }

        public static CommandResult Warning(string warningMessage, string detailedMessage)
        {
            return new CommandResult(CommandExitStatus.Warning, warningMessage, detailedMessage);
        }
    }
}